package com.pratik.gedcom.builder.implementation;

import java.util.List;

import com.pratik.gedcom.builder.interfaces.GedcomBuilder;
import com.pratik.gedcom.domain.Gedcome;
import com.pratik.gedcom.mapper.TokenToGedcomMapper;

public class GedcomBuilderImplementation implements GedcomBuilder {

	private TokenToGedcomMapper gedcomMapper;

	@Override
	public Gedcome build(List<String> tokenList) {
		Gedcome rootGedcome = new Gedcome();
		rootGedcome.setTag("gedcom");
		rootGedcome.setLevel(-1);
		for (int i=0;i<tokenList.size();i++) {
			Gedcome childGedcome = gedcomMapper.mapToGedcome(tokenList.get(i));
			rootGedcome.addChild(childGedcome);
		}
		return rootGedcome;
	}

	public void setGedcomeMapper(TokenToGedcomMapper gedcomMapper) {
		this.gedcomMapper = gedcomMapper;

	}

}
